﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LabNet.Server.Contract;

namespace LabNet.Core.ViewModels
{
    public class GridUserModel
    {
        protected IUserService UserService;

        public GridUserModel(IUserService userService)
        {
            this.UserService = userService;
        }

        public GridUserModel()
        {
            // TODO: Complete member initialization
        }

        public virtual async Task<IList<GridUserModel>> GetModels()
        {
            var results = await UserService.GetAsync();
            var model = new List <GridUserModel>();
            if (results.Any())
            {
                foreach (var result in results)
                {
                    var userIems = new GridUserModel
                    {
                        Id =  result.Id,
                        Name = result.Name,
                        UserName =  result.UserName,
                        Email = result.Email
                    };
                    model.Add(userIems);
                }
            }

            return model;
        }

        public long Id { get; set; }
        public string Name { get; set; }
        public string UserName { get; set; }
        public string Email { get; set; }
    }
}
